home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / nacs.arc / NASIFACE.ASM < prev    next >
Assembly Source File  |  1989-09-26  |  6KB  |  353 lines

  1. ;/* NASIFACE.ASM
  2. ;*
  3. ;* NASI interFACE function calls 
  4. ;*
  5. ;* ARGUMENT:
  6. ;*    
  7. ;*
  8. ;* DESRCIPTION:
  9. ;*    
  10. ;*
  11. ;* RETURNS:
  12. ;*
  13. ;* 
  14. ;* AUTHOR:
  15. ;*    Kamy Rahimi  17-JUN-1989  14:33:19.84
  16. ;*    Copyright (C) 1989 Novell, Inc. CPD
  17. ;* 
  18. ;*
  19. ;* MODIFICATIONS:
  20. ;*
  21. ;*/
  22.  
  23.     .MODEL    SMALL,C
  24.     .DATA
  25.  
  26. PortNumber    DB    0
  27.  
  28. NASI_INIT_BUF    DB    14 DUP (0)
  29. NASI_REQUEST_BUF DB    13 DUP (0)
  30. NASI_REPLY_BUF    DB    13 DUP (0)
  31.  
  32. MatchPattern    DB    30 DUP (0)
  33.  
  34.     .CODE
  35.  
  36. ;/*************************************************************/
  37. ; This routine checks to see if NASI is loaded - DOS 21H
  38. ;
  39. ; int    IsNasiLoaded (void)
  40. ;
  41.  
  42.     PUBLIC IsNasiLoaded
  43.  
  44. _NAME    DB    "NCSI"
  45.  
  46. IsNasiLoaded    PROC  
  47.  
  48.     PUSH    BP
  49.     MOV    BP, SP
  50.     PUSH    DS
  51.     PUSH    SI
  52.     PUSH    DI
  53.     PUSH    CS        ; DS=CS
  54.     POP    DS
  55.     MOV    AX, 356BH    ; Get address of int vector
  56.     INT    21H
  57.  
  58. ; Now ES:BX contains the CS:IP int vector for  NASI
  59.  
  60.     MOV    DI, BX
  61.     LEA    DI, [BX+3]    ; ES:DI points to start of NASI string
  62.     MOV    SI, OFFSET _NAME ; DS:SI points to "NASI"
  63.     MOV    CX, 4        ; COUNT
  64.     CLD            ; Clear the flags
  65.     XOR    AX, AX 
  66.     REPE    CMPSB        ; Compare the strings
  67.     JNE    NOT_LOADED    ; If the string doesn't compare
  68.     INC    AX        ; TRUE return code
  69.  
  70. NOT_LOADED:
  71.     POP    DI
  72.     POP    SI
  73.     POP    DS
  74.     POP    BP
  75.     RET
  76.  
  77. IsNasiLoaded    ENDP 
  78.  
  79. ;/**************************************************************/
  80. ; This routine allocates a virtual circuit - function 11h
  81. ;
  82. ;  char    AllocateCircuit (void)
  83. ;
  84. ; returns: Virtual Circuit Number
  85. ;
  86.  
  87.     PUBLIC AllocateCircuit
  88.  
  89. AllocateCircuit    PROC  
  90.  
  91.     PUSH    BP
  92.     MOV    BP, SP
  93.     MOV    AH, 11H
  94.     MOV    AL, 0        
  95.     INT    6BH
  96.     JC    NASI_ERR01
  97.     XOR    AH, AH 
  98.     JMP    SHORT OK
  99. NASI_ERR01:
  100.     MOV    AX, -1        ; Error 
  101. OK:
  102.     POP    BP
  103.     RET    
  104.  
  105. AllocateCircuit    ENDP
  106.  
  107. ;/**************************************************************/
  108. ; This routine queries the name services to find and return
  109. ; a port name record - function 21H
  110. ;
  111. ; NACSPort far *QueryName (VirtualCircuitNumber, NACSPort far *)
  112. ;
  113.     
  114.     PUBLIC    QueryName
  115.  
  116. QueryName    PROC  
  117.  
  118.     PUSH    BP
  119.     MOV    BP, SP
  120.     MOV    AL, [BP+4]    ; 1st Arg.
  121.     PUSH    DS
  122.     POP    ES
  123.     MOV    BX, [BP+6]    ; 2nd Arg. is the port pattern struct
  124.     MOV    AH, 21H
  125.     MOV    CL, 0H        ; Sets service name
  126.  
  127. ; ES:BX Request match pattern 
  128.  
  129.     MOV    CL, 0
  130.     INT    6BH
  131.     JC    NASI_ERR02
  132.  
  133. ; ES:BX Request data  
  134.  
  135.     MOV    DX, ES
  136.     MOV    AX, BX        ; The port pattern
  137.     JMP    SHORT GO_ON
  138. NASI_ERR02:
  139.     MOV    AX, -1        ; Error 
  140. GO_ON:
  141.     POP    BP
  142.     RET
  143.  
  144. QueryName    ENDP
  145.  
  146. ;/****************************************************************/
  147. ; This routine allows you to set or get the port parameters i.e. 
  148. ; baud rate, parity,... - funtion 15H
  149. ;
  150. ; int    VirtualCircuitConfig (VirtualCircuitNumber, ConfigBuff, option)
  151. ;
  152. ;    option = 1    set configuration
  153. ;         0    get configuration
  154. ;
  155.  
  156.     PUBLIC    VirtualCircuitConfig
  157.  
  158. VirtualCircuitConfig    PROC  
  159.     
  160.     PUSH    BP
  161.     MOV    BP, SP
  162.     MOV    AL, [BP+4]        ; 1st Arg.
  163.     PUSH    DS
  164.     POP    ES
  165.     MOV    BX, [BP+6]        ; 2nd Arg.
  166.     MOV    CL, [BP+8]        ; set or get the config
  167.     MOV    AH, 15H
  168.  
  169. ; ES:BX Addres of request or reply buffer
  170.  
  171.     INT    6BH
  172.     JC    NASI_ERR03
  173.  
  174. ; ES:BX Request data  
  175.  
  176. NASI_ERR03:
  177.     MOV    AX, -1            ; Error 
  178.     POP    BP
  179.     RET
  180.     
  181. VirtualCircuitConfig ENDP
  182.  
  183. ;/****************************************************************/
  184. ; This routine initializes the given virtual circuit -
  185. ; function 16H
  186. ;
  187. ; int    InitVirtualCircuit (VirtualCircuitNumber, NACSPort far *)
  188. ;
  189. ;
  190.     PUBLIC    InitVirtualCircuit
  191.  
  192. InitVirtualCircuit    PROC  
  193.  
  194.     PUSH    BP
  195.     MOV    BP, SP
  196.     MOV    AL, [BP+4]        ; 1st Arg 
  197.     PUSH    DS
  198.     POP    ES
  199.     MOV    BX, [BP+6]        ; 2nd Arg. is the port pattern struct
  200.     MOV    AH, 16H
  201.     XOR    BX, BX
  202.     INT    6BH
  203.     JC    NASI_ERR08
  204.     MOV    PortNumber, AL
  205.     JMP    SHORT OK_INIT
  206. NASI_ERR08:
  207.     MOV    AX, -1            ; CL contains the error 15h or feh
  208. OK_INIT:
  209.     POP    BP
  210.     RET
  211.  
  212. InitVirtualCircuit ENDP
  213.  
  214. ;/**************************************************************/
  215. ; This routine checks the receive status - function 1AH
  216. ;
  217. ; int    RXStatus (VirtualCircuitNumber)
  218. ;
  219. ;
  220.     PUBLIC    RXStatus
  221.  
  222. RXStatus    PROC
  223.  
  224.     PUSH    BP
  225.     MOV    BP, SP
  226.     MOV    AH, 1AH
  227.     MOV    AL, [BP+4]        ; 1st Arg.
  228.     INT    6BH
  229.     JNC    STAT_OK
  230.     MOV    AX, -1
  231. STAT_OK:
  232.     POP    BP
  233.     RET
  234.     
  235. RXStatus    ENDP
  236.  
  237. ;/**************************************************************/
  238. ; This routine reads x number of bytes - function 19H
  239. ;
  240. ; int    NASIRead (VirtualCircuitNumber, ReceiveBuff, x)
  241. ;
  242. ;
  243.  
  244.     PUBLIC    NASIRead
  245.  
  246. NASIRead    PROC
  247.  
  248.     PUSH    BP
  249.     MOV    BP, SP
  250.     MOV    AL, [BP+4]        ; 1st Arg.
  251.     PUSH    DS
  252.     POP    ES
  253.     MOV    BX, [BP+6]        ; 2rd Arg. is input buffer
  254.     MOV    CX, [BP+8]        ; 3nd Arg. is NumberOfChars
  255.     MOV    AH, 19H
  256.     INT    6BH
  257.     JC    NASI_ERR05        ; Error if CX is zero
  258.     MOV    AX, CX            ; CX contains number of written chars
  259.     JMP    SHORT OK_READ
  260. NASI_ERR05:
  261.     XOR    AX, AX
  262. OK_READ:
  263.     POP    BP
  264.     RET
  265.  
  266. NASIRead    ENDP
  267.  
  268. ;/**************************************************************/
  269. ; This routine checks the transmit status - function 1BH
  270. ;
  271. ; int    TXStatus (VirtualCircuitNumber)
  272. ;
  273. ;
  274.  
  275.     PUBLIC    TXStatus
  276.  
  277. TXStatus    PROC
  278.  
  279.     PUSH    BP
  280.     MOV    BP, SP
  281.     MOV    AH, 1BH
  282.     MOV    AL, [BP+4]        ; 1st Arg.
  283.     INT    6BH
  284.     JNC    TX_STAT_OK
  285.     MOV    AX, -1
  286. TX_STAT_OK:
  287.     POP    BP
  288.     RET
  289.     
  290. TXStatus    ENDP
  291.  
  292. ;/**************************************************************/
  293. ; This routine writes x number of bytes - funtion 18H
  294. ;
  295. ; int    NASIWrite (VirtualCircuitNumber, TransmitBuff, x)
  296. ;
  297. ;
  298.     PUBLIC    NASIWrite
  299.  
  300. NASIWrite    PROC
  301.  
  302.     PUSH    BP
  303.     MOV    BP, SP
  304.     MOV    AL, [BP+4]        ; 1st Arg.
  305.     PUSH    DS
  306.     POP    ES
  307.     MOV    BX, [BP+6]        ; 2rd Arg is input buffer
  308.     MOV    CX, [BP+8]        ; 3nd Arg is NumberOfChars
  309.     MOV    AH, 18H
  310.     INT    6BH
  311.     JC    NASI_ERR04        ; Error if CX=0
  312.     MOV    AX, CX              ; CX contains number written chars
  313.     JMP    SHORT OK_WRITE
  314. NASI_ERR04:
  315.     MOV    AX, -1
  316. OK_WRITE:
  317.     POP    BP
  318.     RET
  319.  
  320. NASIWrite    ENDP
  321.  
  322. ;/**************************************************************/
  323. ; This routine disconnects the virtual circuit from the 
  324. ; NACS server - function 17H
  325. ;
  326. ; int    NASIDisconnect (VirtualCircuitNumber)
  327. ;
  328. ;
  329.  
  330.     PUBLIC    NASIDisconnect
  331.  
  332. NASIDisconnect    PROC
  333.  
  334.     PUSH    BP
  335.     MOV    BP, SP
  336.     MOV    AH, 17H
  337.     MOV    AL, [BP+4]        ; 1st Arg.
  338.     INT    6BH
  339.     CMP    AL, 0H
  340.     JE    DISC_OK
  341.     MOV    AX, -1
  342. DISC_OK:
  343.     POP    BP
  344.     RET
  345.     
  346. NASIDisconnect    ENDP
  347.  
  348.     END
  349.  
  350.  
  351.  
  352.                            
  353.